{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Title: #Percentage of Letter in String"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Difficulty: #Easy"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Category Title: #Algorithms"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Tag Slug: #string"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Name Translated: #字符串"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solution Name: percentageLetter"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Title: #字母在字符串中的百分比"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Translated Content:\n",
    "<p>给你一个字符串 <code>s</code> 和一个字符 <code>letter</code> ，返回在 <code>s</code> 中等于&nbsp;<code>letter</code>&nbsp;字符所占的 <strong>百分比</strong> ，向下取整到最接近的百分比。</p>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>示例 1：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"foobar\", letter = \"o\"\n",
    "<strong>输出：</strong>33\n",
    "<strong>解释：</strong>\n",
    "等于字母 'o' 的字符在 s 中占到的百分比是 2 / 6 * 100% = 33% ，向下取整，所以返回 33 。\n",
    "</pre>\n",
    "\n",
    "<p><strong>示例 2：</strong></p>\n",
    "\n",
    "<pre>\n",
    "<strong>输入：</strong>s = \"jjjj\", letter = \"k\"\n",
    "<strong>输出：</strong>0\n",
    "<strong>解释：</strong>\n",
    "等于字母 'k' 的字符在 s 中占到的百分比是 0% ，所以返回 0 。</pre>\n",
    "\n",
    "<p>&nbsp;</p>\n",
    "\n",
    "<p><strong>提示：</strong></p>\n",
    "\n",
    "<ul>\n",
    "\t<li><code>1 &lt;= s.length &lt;= 100</code></li>\n",
    "\t<li><code>s</code> 由小写英文字母组成</li>\n",
    "\t<li><code>letter</code> 是一个小写英文字母</li>\n",
    "</ul>\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Description: [percentage-of-letter-in-string](https://leetcode.cn/problems/percentage-of-letter-in-string/description/)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Solutions: [percentage-of-letter-in-string](https://leetcode.cn/problems/percentage-of-letter-in-string/solutions/)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "test_cases = ['\"foobar\"\\n\"o\"', '\"jjjj\"\\n\"k\"']"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        nums = 0\n",
    "        for _ in s:\n",
    "            if _ == letter:\n",
    "                nums += 1\n",
    "        return int(nums / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        num = 0\n",
    "        for i in s :\n",
    "            if i == letter:\n",
    "                num +=1\n",
    "        res = int(num*100/len(s))\n",
    "        return res"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        k = s.count(letter)\n",
    "        return k * 100 // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return s.count(letter) * 100 // len(s)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return (s.count(letter)*100)//len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count+=1\n",
    "        return int((count/len(s))*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter)/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = s.count(letter)\n",
    "        return 100*n // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        nums = 0\n",
    "        for _ in s:\n",
    "            if _ == letter:\n",
    "                nums += 1\n",
    "        return int(nums / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        k = Counter(s)\n",
    "        return int(k[letter]/n*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = 0\n",
    "        for ss in s:\n",
    "            if ss == letter:\n",
    "                count += 1\n",
    "        return count * 100 // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter) / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return Counter(s)[letter]*100//len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = 0\n",
    "        for s01 in s:\n",
    "            if s01 == letter:\n",
    "                count = count + 1\n",
    "        return 100 * count//len(s)\n",
    "\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        cnt = 0\n",
    "        for ch in s:\n",
    "            if ch == letter:\n",
    "                cnt += 1\n",
    "        return 100 * cnt // n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "         return int(s.count(letter) * 100 / len(s) )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100.0 * s.count(letter) / len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        if letter not in s:\n",
    "            return 0\n",
    "        length = len(s)\n",
    "        count = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1 \n",
    "        return count * 100 // length "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        cnt = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                cnt += 1\n",
    "        return int(cnt/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return (100*s.count(letter)//len(s))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return s.count(letter) * 100 // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        cnt=0\n",
    "        for ch in s:\n",
    "            if ch==letter:\n",
    "                cnt+=1\n",
    "        return 100*cnt//n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        t = [0] * 26\n",
    "        a = ord('a')\n",
    "        for c in s:\n",
    "            t[ord(c) - a] += 1\n",
    "        return floor((t[ord(letter) - a] / sum(t)) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return 100 * s.count(letter) // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        total=len(s)\n",
    "        cnt=s.count(letter)\n",
    "        return int(cnt/total*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        c = Counter(s)\n",
    "        return c[letter] * 100 // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100.0*s.count(letter)/len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        a=s.count(letter)\n",
    "        b=len(s)\n",
    "        c=int(a/b*100)\n",
    "        return c"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "import math\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        counter = 0\n",
    "\n",
    "        for char in s:\n",
    "            if char == letter:\n",
    "                counter += 1\n",
    "        \n",
    "        return math.floor(counter / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        total=len(s)\n",
    "        cnt=s.count(letter)\n",
    "        return int(cnt*100/total)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        # count=0\n",
    "        # for i in s:\n",
    "        #     if i==letter:\n",
    "        #         count+=1\n",
    "        # return int(count/len(s)*100)\n",
    "        return int(s.count(letter)/len(s)*100)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        c = 0;\n",
    "        for i in s:\n",
    "            if i==letter:\n",
    "                c+=1\n",
    "        return int(c *100/len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return s.count(letter)*100//len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return s.count(letter) * 100 // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = 0\n",
    "        for i in range(0,len(s)):\n",
    "            if s[i] == letter:\n",
    "                count += 1\n",
    "            i += 1\n",
    "        return math.floor(count/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from collections import Counter\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        cnt = Counter(s)\n",
    "\n",
    "        return int(cnt[letter] * 100 // len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        count = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1\n",
    "        return int(count/n*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        num = 0\n",
    "        for i in s:\n",
    "            if i==letter:\n",
    "                num+=1\n",
    "        return (int(num*100/len(s)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = k = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1\n",
    "            k += 1\n",
    "        return int(count*100/k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100.0 * s.count(letter) / len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100 * s.count(letter) / len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter) / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100*(s.count(letter)/len(s)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        nums = 0\n",
    "        for _ in s:\n",
    "            if _ == letter:\n",
    "                nums += 1\n",
    "        return int(nums / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        num = 0\n",
    "        for i in s:\n",
    "            if i==letter:\n",
    "                num+=1\n",
    "        return (int(num*100/len(s)))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "from collections import Counter\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        cnt = Counter(s)\n",
    "\n",
    "        return int(cnt[letter] * 100 // len(s))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "\n",
    "        n = len(s)\n",
    "        dic = {}\n",
    "        for ch in s:\n",
    "            if ch not in dic:\n",
    "                dic[ch] = 1\n",
    "            else:\n",
    "                dic[ch] += 1\n",
    "        if letter not in s:\n",
    "            return 0\n",
    "        res = dic[letter]\n",
    "        ans = int(res*100/n)\n",
    "        return ans "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count=0\n",
    "        for i in s:\n",
    "            if i==letter:\n",
    "                count+=1\n",
    "        return int(count/len(s)*100)\n",
    "\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter)/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "'''\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        if letter not in s:\n",
    "            return 0\n",
    "        length = len(s)\n",
    "        count = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1 \n",
    "        return count * 100 // length \n",
    "'''\n",
    "'''\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter) / len(s) * 100)\n",
    "'''\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100.0 * s.count(letter) / len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count=0\n",
    "        for i in range(len(s)):\n",
    "            if s[i]==letter:\n",
    "                count+=1\n",
    "        return math.floor(100*count/len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        dic = {}\n",
    "        for ch in s:\n",
    "            if ch not in dic:\n",
    "                dic[ch] = 1\n",
    "            else:\n",
    "                dic[ch] += 1\n",
    "        if letter not in s:\n",
    "            return 0\n",
    "        res = dic[letter]\n",
    "        ans = int(res*100/n)\n",
    "        return ans "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter) / len(s) * 100) "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        num = 0\n",
    "        for ch in s:\n",
    "            if ch == letter:\n",
    "                num += 1\n",
    "        return num * 100 // len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n=len(s)\n",
    "        c=s.count(letter)\n",
    "        return int(c/n*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return s.count(letter)*100//len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        c = 0;\n",
    "        for i in s:\n",
    "            if i==letter:\n",
    "                c+=1\n",
    "        return int(c *100/len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = s.count(letter)\n",
    "        n = len(s)\n",
    "        ans = (count / n) * 100\n",
    "        return int(ans)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        freq=Counter(s)\n",
    "        n=len(s)\n",
    "        return int(freq[letter]*100/n)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        a = Counter(s)\n",
    "        return int(a[letter] / n * 100) if a[letter] else 0\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = k = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1\n",
    "            k += 1\n",
    "        return int(count*100/k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(100.0 * s.count(letter) / len(s))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = k = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1\n",
    "            k += 1\n",
    "        return int((count / k) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter)/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        k = s.count(letter) / len(s)\n",
    "        return int(k * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                n += 1\n",
    "        return int(n/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter) / len(s) * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        dd=Counter(s)\n",
    "        return int (dd[letter]/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return s.count(letter)*100//len(s)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        n = len(s)\n",
    "        count = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1\n",
    "        return int(count / n * 100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count = k = 0\n",
    "        for i in s:\n",
    "            if i == letter:\n",
    "                count += 1\n",
    "            k += 1\n",
    "        return int(count*100 / k)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(s.count(letter) / len(s) * 100 )"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        return int(Counter(s)[letter]/len(s)*100)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from typing import List\n",
    "import collections\n",
    "\n",
    "class Solution:\n",
    "    def percentageLetter(self, s: str, letter: str) -> int:\n",
    "        count=Counter(s)\n",
    "        return int(count[letter]/len(s)*100)"
   ]
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 2
}
